﻿Imports System.Data.SqlClient

Public Class clsBaja
    Private mintIdBaja As Integer
    Private mintidEmpleado As Integer
    Private mdatFechaBaja As Date
    Private mstrCausaBaja As String
    Private mstrCapturo As String
    Private mstrReportado As String
    Private mstrFiniquito As String
    Public Property IdBaja() As Integer
        Get
            Return mintIdBaja
        End Get
        Set(ByVal value As Integer)
            mintIdBaja = value
        End Set
    End Property

    Public Property idempleado() As Integer
        Get
            Return mintidEmpleado
        End Get
        Set(ByVal value As Integer)
            mintidEmpleado = value
        End Set
    End Property
    Public Property FechaBaja() As Date
        Get
            Return mdatFechaBaja
        End Get
        Set(ByVal value As Date)
            mdatFechaBaja = value
        End Set
    End Property

    Public Property CausaBaja() As String
        Get
            Return mstrCausaBaja
        End Get
        Set(ByVal value As String)
            mstrCausaBaja = value
        End Set
    End Property
    Public Property Capturo() As String
        Get
            Return mstrCapturo
        End Get
        Set(ByVal value As String)
            mstrCapturo = value
        End Set
    End Property
    Public Property Reportado() As String
        Get
            Return mstrReportado
        End Get
        Set(ByVal value As String)
            mstrReportado = value
        End Set
    End Property
    Public Property Finiquito() As String
        Get
            Return mstrFiniquito
        End Get
        Set(ByVal value As String)
            mstrFiniquito = value
        End Set
    End Property
    
    Public Sub New()
        mintIdBaja = 0
        mintidEmpleado = 0
        mdatFechaBaja = Now()
        mstrCausaBaja = ""
        mstrCapturo = ""
        mstrReportado = ""
        mstrFiniquito = ""
    End Sub
    Public Sub Insertar()
        Dim sql As String = "Insert Into Bajas (" & _
                            "IdBaja," & _
                            "IdEmpleado," & _
                            "FechaBaja," & _
                            "CausaBaja," & _
                            "Capturo," & _
                            "Reportado," & _
                            "Finiquito)" & _
                            "VALUES (" & _
                            "@IdBaja," & _
                            "@IdEmpleado," & _
                            "@FechaBaja," & _
                            "@CausaBaja," & _
                            "@Capturo," & _
                            "@Reportado," & _
                            "@Finiquito)"

        Dim cnConn As New SqlConnection
        cnConn.ConnectionString = CitraConnection

        Dim Command As New SqlCommand(sql, cnConn)

        Command.Parameters.AddWithValue("IdBaja", mintIdBaja)
        Command.Parameters.AddWithValue("IdEmpleado", mintidEmpleado)
        Command.Parameters.AddWithValue("FechaBaja", mdatFechaBaja)
        Command.Parameters.AddWithValue("CausaBaja", mstrCausaBaja)
        Command.Parameters.AddWithValue("Capturo", mstrCapturo)
        Command.Parameters.AddWithValue("Reportado", mstrReportado)
        Command.Parameters.AddWithValue("Finiquito", mstrFiniquito)


        cnConn.Open()
        Dim RowsAffected As Integer = Command.ExecuteNonQuery

        If RowsAffected > 0 Then
            cnConn.Close()
        Else
            MsgBox("No fue posible insertar el registro ", MsgBoxStyle.Exclamation, "Aviso")
            If cnConn.State = ConnectionState.Open Then
                cnConn.Close()
            End If
        End If
    End Sub
End Class
